package com.hzdl.car.contorlle;

import com.hzdl.car.bean.User;
import com.hzdl.car.service.MenuService;
import com.hzdl.car.vo.TreeNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RequestMapping("index")
@Controller
public class IndexContorlle {
    @Autowired
    private MenuService menuService;

    @RequestMapping("init")
    public String index(){
        return "index";
    }

    @RequestMapping("leftMenu")
    @ResponseBody
    public Map<String,Object> leftMenu(HttpSession session){
        Object obj = session.getAttribute("session_user");
        User user =(User)obj;
        List<TreeNode> list=null;
        if (user.getType()==1){
             list = menuService.findByPid(1);
        }else{
            list=menuService.findByUid(user.getUserid());
        }
        Map<String,Object> map= new HashMap<>();
        map.put("contentManagement",list);
        return map;
    }

    @RequestMapping("menuInit")
    public String menuInit(){
        return "/amenu/menuManager";
    }

    @RequestMapping("menuLeft")
    public  String menuLeft(){
        return "/amenu/menuLeft";
    }

    @RequestMapping("menuRight")
    public  String menuRight(){
        return "/amenu/menuRight";
    }

    // 显示角色管理jsp
    @RequestMapping("roleMgrInit")
    public String roleMgrInit(){
        return "/role/roleManager";
    }

    // 显示用户管理jsp
    @RequestMapping("userMgrInit")
    public String userMgrInit(){
        return "/user/userManager";
    }

    // 显示日志管理jsp
    @RequestMapping("logMgrInit")
    public String logMgrInit(){
        return "/log/logManager";
    }

    // 显示公告管理jsp
    @RequestMapping("newsMgrInit")
    public String newMgrInit(){
        return "/news/newsManager";
    }


    // 显示客户管理jsp
    @RequestMapping("customerMgrInit")
    public String customerMgrInit(){
        return "/customer/customerManager";
    }

    // 显示车辆管理jsp
    @RequestMapping("carMgrInit")
    public String carMgrInit(){
        return "/carmanager/carManager";
    }

    // 显示汽车出租jsp
    @RequestMapping("buscarMgrInit")
    public String buscarMgrInit(){
        return "/carmanager/buscarManager";
    }

    // 显示出租单jsp
    @RequestMapping("rentMgrInit")
    public String rentMgrInit(){
        return "/rent/rentManager";
    }

    // 显示汽车入库jsp
    @RequestMapping("checkMgrInit")
    public String checkMgrInit(){
        return "/check/checkManager";
    }

    // 显示汽车入库jsp
    @RequestMapping("checkAllMgrInit")
    public String checkAllMgrInit(){
        return "/check/checkAllManager";
    }

    // 显示客户地区统计jsp
    @RequestMapping("echartsMgrInit")
    public String echartsMgrInit(){
        return "/echarts/echarts";
    }

    //显示公司年度月份销售额
    @RequestMapping("salesVolumeInit")
    public String salesVolumeInit(){
        return "/echarts/salesVolume";
    }

    //显示业务员年度销售额
    @RequestMapping("salesmanSalesInit")
    public String salesmanSalesInit(){
        return "/echarts/salesmanSales";
    }

}
